* Symptoms and Stereotypes: Perceptions and Responses to Covid-19 in Malawi and Zambia
*
* Code Authors: Cecilia Ahsan Jansson and Erica Ann Metheney 
*
* Last Updated: October 27th, 2022. 

*This file prepares the three main datasets used for analysis; MCSR1, MCSR2 and ZCSR1 


* -------------------------MALAWI ROUND 1

cd "C:\Users\xahsce\Documents\Projects\Covid-19 Stereotypes Experiment\Data\Malawi R1"

*Importing the raw data 
clear 

use "C:\Users\xahsce\Documents\Projects\Covid-19 Stereotypes Experiment\Malawi R1\Data\MalawiCovidDataRaw.dta"

*------------------------PREPARE DATA 

*Treatment Attribute Preparation 
gen NeighborAge= 1 if Q_38!= "" & Q_38!="."
replace NeighborAge= 2 if Q_38== "60 year old"
label define NeighborAge 1 "25 Years Old" 2 "60 Years Old"
label value NeighborAge NeighborAge

gen NeighborGender= 1 if Q_39!= "" & Q_39!="."
replace NeighborGender= 2 if Q_39== "woman"
label define NeighborGender 1 "Male" 2 "Female"
label value NeighborGender NeighborGender

gen NeighborTimeInCommunity= 1 if Q_40!= "" & Q_40!="."
replace NeighborTimeInCommunity= 2 if Q_40== "a few months"
label define NeighborTimeInCommunity 1 "Many Years" 2 "A Few Months" 
label value NeighborTimeInCommunity NeighborTimeInCommunity

gen NeighborFamilyOrigin= 1 if Q_41!= "" & Q_41!="."
replace NeighborFamilyOrigin= 2 if Q_41== "Mmwenye"
replace NeighborFamilyOrigin= 3 if Q_41== "Zambian"
label define NeighborFamilyOrigin 1 "Malawian" 2 "Mmwenye" 3 "Zambian"
label value NeighborFamilyOrigin NeighborFamilyOrigin

gen OutsiderTreatment= 0 if NeighborFamilyOrigin!=. 
replace OutsiderTreatment= 1 if NeighborFamilyOrigin==2 | NeighborFamilyOrigin==3
label define OutsiderTreatment 0 "Insider" 1 "Outsider"
label value OutsiderTreatment OutsiderTreatment

gen NeighborSymptoms= 1 if Q_42!= "" & Q_42!="."
replace NeighborSymptoms= 2 if Q_42== "a high fever"
replace NeighborSymptoms= 3 if Q_42== "a bad cough and high fever"
label define NeighborSymptoms  1 "Injured Leg" 2 "High Fever" 3 "Cough and High Fever" 
label value NeighborSymptoms NeighborSymptoms 

*Prepare Dependent Variables

*Help: If this person needed you to accompany him/her to the hospital, would you help him/her?
gen Help= 0 if Q_44!= "" & Q_44!= "Don't Know/Refuse to Answer" & Q_44!="."
replace Help= 1 if Q_44== "Yes"
label value Help YesNo

*Move Freely: Do you think this person should be allowed to move freely about the community or made to stay at home?
gen MoveFreely= 0 if Q_46!= "" & Q_46!= "Don't Know/Refuse to Answer" & Q_46!="."
replace MoveFreely= 1 if Q_46== "Move freely"
label value MoveFreely YesNo

*Has Covid: Do you think this person has Covid-19/the corona virus?
*Note here that people who are not sure what Covid-19 is are excluded from the analysis. 
gen HasCovid= 0 if Q_47!= "" & Q_47!= "Not sure what COVID-19/corona virus is" & Q_47!= "Refuse to Answer" & Q_47!="."
replace HasCovid= 1 if Q_47== "Yes"
label value HasCovid YesNo

*Prepare Respondent Characteristics 

*Gender
gen Gender= 0 if Q_22=="Male"
replace Gender= 1 if Q_22=="Female"

label define NGender 0 "Male" 1 "Female"
label value Gender NGender 

*Age 
gen Age= Q_23
replace Age=. if Age>100
replace Age=. if Age<18

*Education
gen Education= 1 if Q_24=="No formal schooling" |strpos(Q_24, "Informal schooling only (including Ko") 
replace Education= 2 if Q_24=="Primary school completed" | Q_24=="Some primary schooling" 
replace Education= 3 if Q_24=="Secondary school/high school completed" |strpos(Q_24, "Intermediate school or some secondary") 
replace Education= 4 if Q_24=="University completed" | Q_24=="Some University" | Q_24=="Post-graduate" | strpos(Q_24, "Post-secondary qualifications")

label define Education 1 "LittleNoSchooling" 2 "PrimarySchooling" 3 "SecondarySchooling" 4 "University"
label value Education Education

*Generate a binary indicator for higher education where this is ==1 if respondent has secondary education or above
gen HigherEducation= 0 if Education!=.
replace HigherEducation=1 if Education==3 | Education==4

*Ethnicity
encode Q_33, gen(Ethnicity)

*Categorical Age (defining three age categories)
gen CtrlAge= 1 if Q_23>17 & Q_23<35
replace CtrlAge=2 if Q_23>34 & Q_23<55
replace CtrlAge= 3 if Q_23>54

*Indicator for if respondent has been surveyed in the 2019 LGPI hh-survey
gen PreviousRespondent = 0 if Q_29 != ""
replace PreviousRespondent = 1 if Q_29 == "Yes"
label define PrevRespM1 0 "No" 1 "Yes"
label value PreviousRespondent PrevRespM1

*Indicates whether respondent has cash paying job
gen CashJob = 0 if Q_111 == "" | Q_111 == "Don't Know/Refuse to Answer"
replace CashJob = 1 if Q_111 == "Yes"
label define Cash 0 "No" 1 "Yes"
label value CashJob Cash

*------------Other Variables 

*Willing to have outsiders as neighbors 
gen ZambianNeighborBias=0 if T_Q_105_1!="" & T_Q_105_1!="Don't Know/Refuse to Answer"
replace ZambianNeighborBias=1 if T_Q_105_1=="No" 

gen IndianNeighborBias=0 if T_Q_105_2!="" & T_Q_105_2!="Don't Know/Refuse to Answer"
replace IndianNeighborBias=1 if T_Q_105_2=="No"

gen CovidNeighborBias=0 if T_Q_105_5!="" & T_Q_105_5!="Don't Know/Refuse to Answer"
replace CovidNeighborBias=1 if T_Q_105_5=="No"


*Respondent is a member of a Politically Salient Group

*Malawi: Chewa, Lhomwe, Ngoni, Tumbuka, Yao
gen SalientGroup=0 if Ethnicity!=. & Ethnicity!=3 & Ethnicity!=2
replace SalientGroup=1 if (Ethnicity==1 | Ethnicity==5 | Ethnicity==22 | Ethnicity==23 | Ethnicity==11)

keep SbjNum CovidPrevalence- SalientGroup T_Q_105_1 T_Q_105_2 T_Q_105_5

drop CovidPrevalence-WillMonitor

rename RespondentRegion region, replace

*Label variables 

label variable SbjNum "Subject number"
label variable T_Q_105_1 "Willing to have Zambian neighbor"
label variable T_Q_105_2 "Willing to have Indian/Amwenye neighbor"
label variable T_Q_105_5 "Willing to have someone with Covid-19 as neighbor"
label variable Ethnicity "Respondents ethnic group"
label variable Gender "Respondents gender" 
label variable CtrlAge "Respondents age" 
label variable Education "Respondents level of education"
label variable NeighborAge "Experimental Attribute: Age"
label variable NeighborGender "Experimental Attribute: Gender"
label variable NeighborTimeInCommunity "Experimental Attribute: Time in Community"
label variable NeighborFamilyOrigin "Experimental Attribute: Family Origin"
label variable OutsiderTreatment "Experimental Attribute:==1 if Neigbor Family Origin ==Indian or ==Zambian"
label variable NeighborSymptoms "Experimental Attribute: Symptoms"
label variable Help "Outcome: willing to help person to hospital"
label variable MoveFreely "Outcome: willing to let person move freely"
label variable HasCovid "Outcome: believes that the person has Covid-19"
label variable Age "Respondents age (non-categorical)"
label variable HigherEducation "Respondent has at least some Secondary Education"
label variable PreviousRespondent "Respondent was interviewed in LGPI 2019"
label variable CashJob "Respondent has a cash paying job"
label variable ZambianNeighborBias "Respondent is not willing to have Zambians as neighbors"
label variable IndianNeighborBias "Respondent is not willing to have Indians/Amwenye as neighbors"
label variable CovidNeighborBias "Respondent is not willing to have people with Covid-19 as neighbors"
label variable SalientGroup "Respondent belongs to a politically salient ethnic group"

*Save Data
save "C:\Users\xahsce\Documents\Projects\Covid-19 Stereotypes Experiment\Data\Malawi R1\MCSR1.dta", replace


*------------------------------MALAWI ROUND 2

clear 

cd "C:\Users\xahsce\Documents\Projects\Covid-19 Stereotypes Experiment\Malawi R3\Data"

*Importing the raw data 
import delimited "Malawi Covid Survey -R3"

*Exclude Pilot Data
drop if strpos(date, "2021-02")
drop if strpos(date, "2021-03-01")
drop if strpos(date, "2021-03-02")
drop if strpos(date, "2021-03-03")

*Drop incomplete surveys 
drop if q_223==""

*--------------------------PREPARE DATA

*Treatments
gen NeighborAge= 1 if q_57!= "" & q_57!="."
replace NeighborAge= 2 if q_57== "60 year old"
label define NeighborAge 1 "25 Years Old" 2 "60 Years Old"
label value NeighborAge NeighborAge

gen NeighborGender= 1 if q_58!= "" & q_58!="."
replace NeighborGender= 2 if q_58== "woman"
label define NeighborGender 1 "Male" 2 "Female"
label value NeighborGender NeighborGender

gen NeighborTimeInCommunity= 1 if q_59!="" & q_59!="."
replace NeighborTimeInCommunity= 2 if q_59== "a few months"
label define NeighborTimeInCommunity 1 "Many Years" 2 "A Few Months" 
label value NeighborTimeInCommunity NeighborTimeInCommunity

gen NeighborFamilyOrigin= 1 if q_60!= "" & q_60!="."
replace NeighborFamilyOrigin= 2 if q_60== "Mmwenye"
replace NeighborFamilyOrigin= 3 if q_60== "Zambian"
label define NeighborFamilyOrigin 1 "Malawian" 2 "Mmwenye" 3 "Zambian"
label value NeighborFamilyOrigin NeighborFamilyOrigin

gen OutsiderTreatment= 0 if NeighborFamilyOrigin!=. 
replace OutsiderTreatment= 1 if NeighborFamilyOrigin==2 | NeighborFamilyOrigin==3
label define OutsiderTreatment 0 "Insider" 1 "Outsider"
label value OutsiderTreatment OutsiderTreatment

gen NeighborSymptoms= 1 if q_61!= "" & q_61!="."
replace NeighborSymptoms= 2 if q_61== "a high fever"
replace NeighborSymptoms= 3 if q_61== "a bad cough and high fever"
label define NeighborSymptoms  1 "Injured Leg" 2 "High Fever" 3 "Cough and High Fever" 
label value NeighborSymptoms NeighborSymptoms 

*Dependent Variables

*Help: If this person needed you to accompany him/her to the hospital, would you help him/her?
gen Help= 0 if q_63!= "" & q_63!= "Don't Know/Refuse to Answer" & q_63!="."
replace Help= 1 if q_63== "Yes"
label value Help YesNo

*Move Freely: Do you think this person should be allowed to move freely about the community or made to stay at home?
gen MoveFreely= 0 if q_65!= "" & q_65!= "Don't Know/Refuse to Answer" & q_65!="."
replace MoveFreely= 1 if q_65== "Move freely"
label value MoveFreely YesNo

*Has Covid: Do you think this person has Covid-19/the corona virus?
gen HasCovid= 0 if q_66!= "" & q_66!= "Not sure what COVID-19/corona virus is" & q_66!= "Refuse to Answer" & q_66!="."
replace HasCovid= 1 if q_66== "Yes"
label value HasCovid YesNo

*Respondent Characteristics 

*Gender
gen Gender= 0 if q_19=="Male"
replace Gender= 1 if q_19=="Female"
label define Gender 0 "Male" 1 "Female"
label value Gender Gender 

*Age 
gen Age= q_17
replace Age=. if Age>100
replace Age=. if Age<18

*Education
gen Education= 1 if q_213=="No formal schooling" |strpos(q_213, "Informal schooling only (including Ko") 
replace Education= 2 if q_213=="Primary school completed" | q_213=="Some primary schooling" 
replace Education= 3 if q_213=="Secondary school/high school completed" |strpos(q_213, "Intermediate school or some secondary") 
replace Education= 4 if q_213=="University completed" | q_213=="Some University" | q_213=="Post-graduate" | strpos(q_213, "Post-secondary qualifications")

label define Education 1 "LittleNoSchooling" 2 "PrimarySchooling" 3 "SecondarySchooling" 4 "University"
label value Education Education

gen HigherEducation= 0 if Education!=.
replace HigherEducation=1 if Education==3 | Education==4

*Ethnicity
encode q_20, gen(Ethnicity)

*Categorical Age
gen CtrlAge= 1 if Age>17 & Age<35
replace CtrlAge=2 if Age>34 & Age<55
replace CtrlAge= 3 if Age>54

*Region
replace q_33="" if q_33=="Don't Know"
encode q_33, gen(Region)

*Unwilling to have outsiders as neighbors 
gen IndianNeighborBias=0 if t_q_212_1!="" & t_q_212_1!="Don't Know/Refuse to Answer"
replace IndianNeighborBias=1 if t_q_212_1=="No"

gen ZambianNeighborBias=0 if t_q_212_2!="" & t_q_212_2!="Don't Know/Refuse to Answer"
replace ZambianNeighborBias=1 if t_q_212_2=="No"

gen CovidNeighborBias=0 if t_q_212_3!="" & t_q_212_3!="Don't Know/Refuse to Answer"
replace CovidNeighborBias=1 if t_q_212_3=="No"

*Has taken either LGPI 2019 or previous Covid-19 surveys 
gen PreviousRespondent = 0 if q_21 != ""
replace PreviousRespondent = 1 if q_21 == "Previous Respondent"
label define PrevRespM3 0 "No" 1 "Yes"
label value PreviousRespondent PrevRespM3

*Respondent belongs to a Politically Salient Group

*Chewa, Lhomwe, Ngoni, Tumbuka, Yao
gen SalientGroup=0 if Ethnicity!=. & Ethnicity!=3 & Ethnicity!=2
replace SalientGroup=1 if (Ethnicity==1 | Ethnicity==6 | Ethnicity==18 | Ethnicity==19 | Ethnicity==9)

keep sbjnum NeighborAge-SalientGroup t_q_212_1 t_q_212_2 t_q_212_3

rename sbjnum SbjNum


label variable SbjNum "Subject number"
label variable t_q_212_2 "Willing to have Zambian neighbor"
label variable t_q_212_1 "Willing to have Indian/Amwenye neighbor"
label variable t_q_212_3 "Willing to have someone with Covid-19 as neighbor"
label variable Ethnicity "Respondents ethnic group"
label variable Gender "Respondents gender" 
label variable CtrlAge "Respondents age" 
label variable Education "Respondents level of education"
label variable NeighborAge "Experimental Attribute: Age"
label variable NeighborGender "Experimental Attribute: Gender"
label variable NeighborTimeInCommunity "Experimental Attribute: Time in Community"
label variable NeighborFamilyOrigin "Experimental Attribute: Family Origin"
label variable OutsiderTreatment "Experimental Attribute:==1 if Neigbor Family Origin ==Indian or ==Zambian"
label variable NeighborSymptoms "Experimental Attribute: Symptoms"
label variable Help "Outcome: willing to help person to hospital"
label variable MoveFreely "Outcome: willing to let person move freely"
label variable HasCovid "Outcome: believes that the person has Covid-19"
label variable Age "Respondents age (non-categorical)"
label variable HigherEducation "Respondent has at least some Secondary Education"
label variable PreviousRespondent "Respondent was interviewed in LGPI 2019"
label variable ZambianNeighborBias "Respondent is not willing to have Zambians as neighbors"
label variable IndianNeighborBias "Respondent is not willing to have Indians/Amwenye as neighbors"
label variable CovidNeighborBias "Respondent is not willing to have people with Covid-19 as neighbors"
label variable SalientGroup "Respondent belongs to a politically salient ethnic group"


*Save Data 
 save "C:\Users\xahsce\Documents\Projects\Covid-19 Stereotypes Experiment\Data\Malawi R2\MCSR2.dta", replace 

*------------------------------------ZAMBIA
clear 

*Import raw data
cd "C:\Users\xahsce\Documents\Covid-19 Stereotypes Experiment\Data\Zambia R1"

import delimited "ZambiaCovidAll"

drop if q_38=="."
drop if q_120==""

*---------------------------------------PREPARE DATA 

*Treatments
gen NeighborAge= 1 if q_38!= "" & q_38!="."
replace NeighborAge= 2 if q_38== "60 year old"
label define NeighborAge 1 "25 Years Old" 2 "60 Years Old"
label value NeighborAge NeighborAge

gen NeighborGender= 1 if q_39!= "" & q_39!="."
replace NeighborGender= 2 if q_39== "woman"
label define NeighborGender 1 "Male" 2 "Female"
label value NeighborGender NeighborGender

gen NeighborTimeInCommunity= 1 if q_40!= "" & q_40!="."
replace NeighborTimeInCommunity= 2 if q_40== "a few months"
label define NeighborTimeInCommunity 1 "Many Years" 2 "A Few Months" 
label value NeighborTimeInCommunity NeighborTimeInCommunity

gen NeighborFamilyOrigin= 1 if q_41!= "" & q_41!="."
replace NeighborFamilyOrigin= 2 if q_41== "Tanzanian"
replace NeighborFamilyOrigin= 3 if q_41== "Zambian"
label define NeighborFamilyOrigin 1 "Malawian" 2 "Tanzanian" 3 "Zambian"
label value NeighborFamilyOrigin NeighborFamilyOrigin

gen OutsiderTreatment= 0 if NeighborFamilyOrigin!=. 
replace OutsiderTreatment= 1 if NeighborFamilyOrigin==1 | NeighborFamilyOrigin==2

label define OutsiderTreatment 0 "Insider" 1 "Outsider"
label value OutsiderTreatment OutsiderTreatment

gen NeighborSymptoms= 1 if q_42!= "" & q_42!="."
replace NeighborSymptoms= 2 if q_42== "high fever"
replace NeighborSymptoms= 3 if q_42== "a bad cough and high fever"
label define NeighborSymptoms  1 "Injured Leg" 2 "High Fever" 3 "Cough & High Fever" 
label value NeighborSymptoms NeighborSymptoms 

*Dependent Variables

*Help: If this person needed you to accompany him/her to the hospital, would you help him/her?
gen Help= 0 if q_44!= "" & q_44!= "Don't Know/Refuse to Answer" & q_44!="."
replace Help= 1 if q_44== "Yes"
label value Help YesNo

*Move Freely: Do you think this person should be allowed to move freely about the community or made to stay at home?
gen MoveFreely= 0 if q_46!= "" & q_46!= "Don't Know/Refuse to Answer" & q_46!="."
replace MoveFreely= 1 if q_46== "Move freely"
label value MoveFreely YesNo

*Has Covid: Do you think this person has Covid-19/the corona virus?
gen HasCovid= 0 if q_47!= "" & q_47!= "Don't Know" & q_47!= "Refuse to Answer" & q_47!="."
replace HasCovid= 1 if q_47== "Yes"
label value HasCovid YesNo

*Willing to have outsiders as neighbors 
gen MalawianNeighborBias=0 if t_q_108_1!="" & t_q_108_1!="Don't Know/Refuse to Answer"
replace MalawianNeighborBias=1 if t_q_108_1=="No"

gen TanzanianNeighborBias=0 if t_q_108_2!="" & t_q_108_2!="Don't Know/Refuse to Answer"
replace TanzanianNeighborBias=1 if t_q_108_2=="No"

gen CovidNeighborBias=0 if t_q_108_5!="" & t_q_108_5!="Don't Know/Refuse to Answer"
replace CovidNeighborBias=1 if t_q_108_5=="No"

*Respondent Characteristics 

*Gender
gen Gender= 0 if q_22=="Male"
replace Gender= 1 if q_22=="Female"
label define Gender 0 "Male" 1 "Female"
label value Gender Gender 

*Age 
gen Age= q_23
replace Age=. if Age>100
replace Age=. if Age<18

*Education
gen Education= 1 if q_24=="No formal schooling" |strpos(q_24, "Informal schooling only (including Ko") 
replace Education= 2 if q_24=="Primary school completed" | q_24=="Some primary schooling" 
replace Education= 3 if q_24=="Secondary school/high school completed" |strpos(q_24, "Intermediate school or some secondary") 
replace Education= 4 if q_24=="University completed" | q_24=="Some University" | q_24=="Post-graduate" | strpos(q_24, "Post-secondary qualifications")

label define Education 1 "LittleNoSchooling" 2 "PrimarySchooling" 3 "SecondarySchooling" 4 "University"
label value Education Education

gen HigherEducation= 0 if Education!=.
replace HigherEducation=1 if Education==3 | Education==4


*Categorical Age
gen CtrlAge= 1 if Age>17 & Age<35
replace CtrlAge=2 if Age>34 & Age<55
replace CtrlAge= 3 if Age>54


*Respondent has taken LGPI 2019
gen PreviousRespondent = 0 if q_29 != ""
replace PreviousRespondent = 1 if q_29 == "Yes"
label define PrevResp 0 "No" 1 "Yes"
label value PreviousRespondent PrevResp

*Respondent belongs to a Politically Salient Group

*Bemba Tonga 
encode q_33, gen(Ethnicity)
gen SalientGroup=0 if Ethnicity!=. & Ethnicity!=5 & Ethnicity!=6
replace SalientGroup=1 if Ethnicity==1 | Ethnicity==32

keep sbjnum NeighborAge- SalientGroup t_q_108_1 t_q_108_2 t_q_108_5

rename sbjnum SbjNum


label variable SbjNum "Subject number"
label variable t_q_108_1 "Willing to have Malawian neighbor"
label variable t_q_108_2 "Willing to have Tanzanian neighbor"
label variable t_q_108_5 "Willing to have someone with Covid-19 as neighbor"
label variable Ethnicity "Respondents ethnic group"
label variable Gender "Respondents gender" 
label variable CtrlAge "Respondents age" 
label variable Education "Respondents level of education"
label variable NeighborAge "Experimental Attribute: Age"
label variable NeighborGender "Experimental Attribute: Gender"
label variable NeighborTimeInCommunity "Experimental Attribute: Time in Community"
label variable NeighborFamilyOrigin "Experimental Attribute: Family Origin"
label variable OutsiderTreatment "Experimental Attribute:==1 if Neigbor Family Origin ==Malawian or ==Tanzanian"
label variable NeighborSymptoms "Experimental Attribute: Symptoms"
label variable Help "Outcome: willing to help person to hospital"
label variable MoveFreely "Outcome: willing to let person move freely"
label variable HasCovid "Outcome: believes that the person has Covid-19"
label variable Age "Respondents age (non-categorical)"
label variable HigherEducation "Respondent has at least some Secondary Education"
label variable PreviousRespondent "Respondent was interviewed in LGPI 2019"
label variable MalawianNeighborBias "Respondent is not willing to have Malawians as neighbors"
label variable TanzanianNeighborBias "Respondent is not willing to have Tanzanians as neighbors"
label variable CovidNeighborBias "Respondent is not willing to have people with Covid-19 as neighbors"
label variable SalientGroup "Respondent belongs to a politically salient ethnic group"


*Save Data
save "C:\Users\xahsce\Documents\Projects\Covid-19 Stereotypes Experiment\Data\Zambia R1\ZCSR1.dta", replace 



